package cn.chencaiju.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.chencaiju.domain.Category;
import cn.chencaiju.service.CategoryService;

@Controller
@RequestMapping("/category/")
public class CategoryController {
	@Autowired
	CategoryService service;
	
	@RequestMapping("/categories")
	@ResponseBody
	public List<Category> findAll(Model model) {
		System.out.println("ctaegory");
		List<Category> list = service.findAll();
		model.addAttribute("categories",list);
		return list;
	}

}
